<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>消耗品领用管理-云校通_教师版</title>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<link rel="stylesheet" href="<%=basePath%>/style/weui.css" />
<link rel="stylesheet" href="<%=basePath%>/css/xcgl_kcgl.css" />
<link rel="stylesheet" href="<%=basePath%>/style/icon.css" />
<style>
  .weui_cells{
  	margin-top: 0 !important;
  }
</style>
</head>

<body ontouchstart>
	<jsp:include page="/WEB-INF/page/common/_header.jsp"></jsp:include>
	<div id="detail" style="padding-bottom: 60px;">
		<div class="weui-header bg-blue">
			<div class="weui-header-left">
				<a onclick="back()" class="icon icon-109 f-white">返回</a>
			</div>
			<h1 class="weui-header-title">库存详情</h1>
		</div>
		<div class="main" style="padding-bottom: 15px;">
                <div class="weui_cells">
               </div>   
		</div>
   </div>
	<jsp:include page="/WEB-INF/page/common/_footer.jsp"></jsp:include>
	<script src="<%=basePath%>/js/zepto.min.js"></script>
	<script src="<%=basePath%>/js/swipe.js"></script>
	
	<script>
	var id = ${id}
		window.onload = function() {
			var page = 0, size = 5;
			$('.main').dropload(
							{
								scrollArea : window,
								autoLoad : true,
								domDown : {
									domClass : 'dropload-down',
									domRefresh : '<div class="dropload-refresh f10 " ><i class="icon icon-20"></i>上拉加载更多</div>',
									domLoad : '<div class="dropload-load f10"><span class="weui-loading"></span>正在加载中...</div>',
									domNoData : '<div class="dropload-noData">没有更多数据了</div>'
								},
								domUp : {
									domClass : 'dropload-up',
									domRefresh : '<div class="dropload-refresh"><i class="icon icon-114"></i>上拉加载更多</div>',
									domUpdate : '<div class="dropload-load f10"><i class="icon icon-20"></i>释放更新...</div>',
									domLoad : '<div class="dropload-load f10"><span class="weui-loading"></span>正在加载中...</div>'
								},
								loadDownFn : function(me) {
									page++;
									window.params = {
										page : page,
										rows : size,
										stockId:id
									};
									$.ajax({
										url : basePath + '/ls/school/property/stock/detail/query',
										type : "post",
										dataType : "json",
										data : window.params,
										success : function(data) {
											if (data.data.rows.length == 0 || window.params.page * window.params.rows >= data.data.total) {
														me.lock();
														me.noData();
											}
													// 为了测试，延迟1秒加载
													setTimeout(
															function() {
																loadDataToHtml(data.data);
																me.resetload();
															}, 500);
												},
										 error : function(xhr, type) {
												}
											});
								}
							});
		}
		function loadDataToHtml(data) {
			if (data.rows.length > 0) {
				var html = "";
				for ( var i in data.rows) {
					var item = data.rows[i];
					var temp = JSON.stringify(item);
					html += '<div class="weui_cell">\
                               <div class="weui_cell_bd weui_cell_primary">\
                                 <p>编号：' + item.goodsNo +'</p>\
                               </div>\
                               <div class="weui_cell_ft">' + status(item.goodsState) +'</div>\
                             </div>';
				}
				$('.weui_cells').append(html);
			}
		}
		function status(i){
			if(i == '0')
				return "在库";
			else if(i == '1')
				return '借出';
			else if(i == '2')
				return "损坏";
		}
	</script>
</body>
</html>